﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Management;
//aspnet_regsql.exe -U userID -P password -S serverName -d database -A w
namespace Infrastructure.Web.HealthMonitoring
{
    public class SkynetWebRequestEvent : System.Web.Management.WebRequestEvent
    {
        private string customCreatedMsg;
        private string customRaisedMsg;
        
        public SkynetWebRequestEvent(
            string msg,
            object eventSource,
            int eventCode)
            :
            base(msg, eventSource, eventCode)
        {            
            customCreatedMsg = string.Format("Event created at: {0}", EventTime.ToString());
        }


        public SkynetWebRequestEvent(
            string msg,
            object eventSource,
            int eventCode,
            int eventDetailCode)
            :
            base(msg, eventSource, eventCode, eventDetailCode)
        {

            customCreatedMsg = string.Format("Event created at: {0}",
                EventTime.ToString());

        }

        // Raises the SampleWebRequestEvent.
        public override void Raise()
        {

            customRaisedMsg = string.Format("Event raised at: {0}", EventTime.ToString());


            base.Raise();
        }

        //Formats Web request event information.
        public override void FormatCustomEventDetails(WebEventFormatter formatter)
        {
            // Add custom data.
            formatter.AppendLine("");

            formatter.IndentationLevel += 1;
            formatter.AppendLine("* Custom Request Information Start *");

            // Display custom event timing.
            formatter.AppendLine(customCreatedMsg);
            formatter.AppendLine(customRaisedMsg);

            formatter.AppendLine("* Custom Request Information End *");

            formatter.IndentationLevel -= 1;
        }
    }
}
